package com.neutech.controller;


import com.neutech.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class RoomController {

    @Autowired
    private RoomService roomService;

    @ResponseBody
    @RequestMapping("/allroom")
    public List<Map<String, Object>> allroom()
    {
        return roomService.queryroom();
    }


    @ResponseBody
    @RequestMapping("/queryroom")
    public List<Map<String, Object>> roomby(@RequestParam Map map)
    {
        List<Map<String, Object>> list = roomService.queryroombyid(Integer.parseInt(map.get("id").toString()));
        return roomService.queryroombyid(Integer.parseInt(map.get("id").toString()));
    }

    @ResponseBody
    @RequestMapping("/addroom")
    public void addroom(@RequestParam Map map)
    {
        for (Object key : map.keySet()) {
            String value = (String)map.get(key);

            System.out.println(key + " : " + value);

        }
        roomService.addroom(map);
    }


    @ResponseBody
    @RequestMapping("/delroom")
    public void delroom(@RequestParam Map map)
    {
        roomService.delroom(Integer.parseInt(map.get("id").toString()));
    }



}
